﻿namespace FSLib

type AnalysisHue() =
    interface IAnalysis with

        member this.FilterName = "AnalysisHue"
        member this.Description = "色相の分布を解析"

        member this.Compute arr =

            let isRed x =
                let (r,g,b) = CommonUtils.toRGBF(x)
                let (h,s,v) = CommonUtils.rgb2hsv(r,g,b)
                (0.0<h && h<30.0 && s>0.8) || (330.0<h && h<360.0 && s>0.8) // 色相が赤系で、彩度が0.8以上を対象にする

            let a = 
                arr
                |> Array.filter(isRed)
                |> Array.length
            
            "Red count Len=" + string a
